﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Infrastructure.Data;
using Keepo.Models;
using AlbumDesigner.Models.Types;
using Keepo.Helpers;
using AlbumDesigner.Models.Enums;
using AlbumDesigner.Helpers;

namespace AlbumDesigner.Controllers
{
    [CheckPermission(section = "FilmingDays")]
    public class FilmingDaysController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult GetFilmingDaysOfMonth(int month, int year)
        {
            using (GenericRepository repository = new GenericRepository())
            {
                month++; //increase the month value as it is smaller by one

                //get all the filming days of the specified month and year
                var filmingDaysList = repository.Find<FilmingDay>(m => m.Date.Month == month && m.Date.Year == year);
                var filmingDays = filmingDaysList.Select(m => new FilmingDayData(m)).ToList();

                return Json(filmingDays);
            }
        }
    }
}
